/*************************************************
Author: will
Date: 9/11/2012
Description:
Notes: 
*************************************************/

#ifndef __CTaskID_h__
#define __CTaskID_h__

#include "CTaskDef.h"

class CTaskID
{
public:

    CTaskID ()
    {
        _uiBranchID = 0;
        _uiTaskID = 0;
    }

    CTaskID (unsigned int uiTaskID)
    {
        _uiBranchID = (unsigned int)uiTaskID / TASK_CONFIG_ID_MOD;
        _uiTaskID = (unsigned int)uiTaskID % TASK_CONFIG_ID_MOD;
    }

    CTaskID& operator=(const CTaskID& stTaskID)
    {
        _uiBranchID = stTaskID._uiBranchID;
        _uiTaskID = stTaskID._uiTaskID;
    
        return *this;
    }

    int Init(CTaskIDData& stData)
    {
        _uiBranchID = stData._uiBranchID;
        _uiTaskID = stData._uiTaskID;

        return 0;
    }

    int GetData(CTaskIDData& stData)
    {
        stData._uiBranchID = _uiBranchID;
        stData._uiTaskID = _uiTaskID;

        return 0;
    }

    bool operator==(const CTaskID& stTaskID) const
    {
        return ((_uiBranchID == stTaskID._uiBranchID)
            && (_uiTaskID == stTaskID._uiTaskID));
    }

    bool operator!= (const CTaskID& stTaskID) const
    {
        return !operator==(stTaskID);
    }

    bool IsMainTask() const
    {
        return _uiBranchID == 0;
    }

    bool IsLessonTask() const 
    {
        return _uiBranchID == 999;
    }

    bool IsRewardTask() const 
    {
        return _uiBranchID == 998;
    }

    void DumpTaskID()
    {
        CT_TRACE(("TaskID: 是否为主线任务 %d, 分支ID %u, 任务ID %u", IsMainTask(), _uiBranchID, _uiTaskID));
    }

public:
    unsigned int _uiBranchID;       //从0开始，最大值为MAX_BRANCH_TASK_CONFIG - 1
    unsigned int _uiTaskID;         //从0开始，最大值为MAX_MAIN_TASK_CONFIG - 1
};


#endif // __CTaskID_h__

